package org.theonept.gwt.svg.dom;

import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Element;

public class SVGDOMImpl {

	public native static Element createSVGElement(Document doc, int boxWidth,
			int boxHeight) /*-{

		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = doc.createElementNS(xmlns, "svg");
		svgElem.setAttributeNS(null, "viewBox", "0 0 " + boxWidth + " "
				+ boxHeight);
		svgElem.setAttributeNS(null, "width", boxWidth);
		svgElem.setAttributeNS(null, "height", boxHeight);
		svgElem.style.display = "block";
		return svgElem;
	}-*/;

	public native static Element createRectElement(Document doc) /*-{
		var e = doc.createElementNS("http://www.w3.org/2000/svg", "RECT");
		e.setAttributeNS(null, "width", "100px");
		e.setAttributeNS(null, "height", "100px");
		e.setAttributeNS(null, "x", "0px");
		e.setAttributeNS(null, "y", "0px");
		return e;
	}-*/;

	public native static Element createLineElement(Document document, int x1,
			int y1, int x2, int y2) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "line");
		svgElem.setAttributeNS(null, "x1", x1);
		svgElem.setAttributeNS(null, "y1", y1);
		svgElem.setAttributeNS(null, "x2", x2);
		svgElem.setAttributeNS(null, "y2", y2);
		svgElem.setAttributeNS(null, 'stroke', "#000000");

		return svgElem;
	}-*/;

	public native static Element createLineElement(Document document) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "line");
		svgElem.setAttributeNS(null, 'stroke', "#000000");

		return svgElem;
	}-*/;

	public native static Element createEllipseElement(Document document,
			int cx, int cy, int rx, int ry) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "ellipse");
		svgElem.setAttributeNS(null, "cx", cx);
		svgElem.setAttributeNS(null, "cy", cy);
		svgElem.setAttributeNS(null, "rx", rx);
		svgElem.setAttributeNS(null, "ry", ry);
		svgElem.setAttributeNS(null, 'stroke', "#000000");

		return svgElem;
	}-*/;

	public native static Element createCircleElement(Document document, int cx,
			int cy, int r) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "circle");
		svgElem.setAttributeNS(null, "cx", cx);
		svgElem.setAttributeNS(null, "cy", cy);
		svgElem.setAttributeNS(null, "r", r);
		svgElem.setAttributeNS(null, "fill", "#FFFFFF");
		svgElem.setAttributeNS(null, 'stroke', "#000000");

		return svgElem;
	}-*/;

	public native static Element createPathElement(Document document, String d) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "path");
		svgElem.setAttributeNS(null, "d", d);
		svgElem.setAttributeNS(null, 'stroke', "#000000");

		return svgElem;
	}-*/;

	public native static Element createPathElement(Document document) /*-{
		var xmlns = "http://www.w3.org/2000/svg";
		var svgElem = document.createElementNS(xmlns, "path");
		svgElem.setAttributeNS(null, 'stroke', "#000000");
		svgElem.setAttributeNS(null, 'fill', "none");
		return svgElem;
	}-*/;

}
